package com.xmfh.wemedia.controller;


import com.xmfh.wemedia.dto.VideoDTO;
import com.xmfh.wemedia.exception.DatabaseInsertionError;
import com.xmfh.wemedia.service.impl.DdPublishLineServiceImpl;
import com.xmfh.wemedia.util.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author admin
 * @since 2022-04-12
 */
@Slf4j
@RestController
@RequestMapping("/wemedia/ddPublishLine")
public class DdPublishLineController {

    @Autowired
    private DdPublishLineServiceImpl service;

    @PostMapping("/insertNewPublishLine")
    public JsonResult<Void> insertNewPublishLine(@RequestBody VideoDTO videoDTO) {
        log.info("INSERT INTO dd_publish_line: {}", videoDTO);
        try {
            service.insertNewPublishLine(videoDTO);
        } catch (DatabaseInsertionError e) {
            return JsonResult.fail(JsonResult.State.DATABASE_ERROR, e.getMessage());
        }
        return JsonResult.ok();
    }
}
